{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "zkufh760uvF3"
   },
   "source": [
    "![JohnSnowLabs](https://nlp.johnsnowlabs.com/assets/images/logo.png)\n",
    "\n",
    "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/JohnSnowLabs/nlu/blob/master/examples/colab/Training/binary_text_classification/NLU_training_sentiment_classifier_demo_reddit.ipynb)\n",
    "\n",
    "\n",
    "# Training a Sentiment Analysis Classifier with NLU\n",
    "## 2 class Reddit comment sentiment classifier training\n",
    "With the [SentimentDL model](https://nlp.johnsnowlabs.com/docs/en/annotators#sentimentdl-multi-class-sentiment-analysis-annotator)  from Spark NLP you can achieve State Of the Art results on any multi class text classification problem\n",
    "\n",
    "This notebook showcases the following features :\n",
    "\n",
    "- How to train the deep learning classifier\n",
    "- How to store a pipeline to disk\n",
    "- How to load the pipeline from disk (Enables NLU offline mode)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "dur2drhW5Rvi"
   },
   "source": [
    "# 1. Install Java 8 and NLU"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "hFGnBCHavltY"
   },
   "outputs": [],
   "source": [
    "!pip install -q johnsnowlabs"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "f4KkTfnR5Ugg"
   },
   "source": [
    "# 2. Download Reddit  Sentiment dataset\n",
    "https://www.kaggle.com/cosmos98/twitter-and-reddit-sentimental-analysis-dataset\n",
    "#Context\n",
    "\n",
    "This is was a Dataset Created as a part of the university Project On Sentimental Analysis On Multi-Source Social Media Platforms using PySpark."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "OrVb5ZMvvrQD"
   },
   "outputs": [],
   "source": [
    "! wget https://s3.amazonaws.com/auxdata.johnsnowlabs.com/public/resources/en/classifier-dl/reddit_twitter_sentiment/Reddit_Data.csv\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 424
    },
    "id": "y4xSRWIhwT28",
    "outputId": "4928f1b2-102c-4519-83f7-6bfa6205749a"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "  <div id=\"df-c75b18be-7c18-4646-8a20-02af38ea4644\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>text</th>\n",
       "      <th>y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>title edit 56dd brend ambasittur for vidya sec...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>this reminds kunkka old dota loading screen ar...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>meanwhile the other news cms intenttarget</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>lovely finish there giroud</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>glad see kurisu made with surprising results d...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>595</th>\n",
       "      <td>true india needs top universities and not fdi...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>596</th>\n",
       "      <td>why did miyaichi come off early</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>597</th>\n",
       "      <td>indian media has lost its credibility now ital...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>598</th>\n",
       "      <td>malaysia french satellite find further debris ...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>599</th>\n",
       "      <td>tell many people you can vote for modi this go...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>600 rows × 2 columns</p>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-c75b18be-7c18-4646-8a20-02af38ea4644')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-c75b18be-7c18-4646-8a20-02af38ea4644 button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-c75b18be-7c18-4646-8a20-02af38ea4644');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "<div id=\"df-903b4e1f-a7f2-420a-986d-a4431648bd9f\">\n",
       "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-903b4e1f-a7f2-420a-986d-a4431648bd9f')\"\n",
       "            title=\"Suggest charts.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "     width=\"24px\">\n",
       "    <g>\n",
       "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
       "    </g>\n",
       "</svg>\n",
       "  </button>\n",
       "\n",
       "<style>\n",
       "  .colab-df-quickchart {\n",
       "      --bg-color: #E8F0FE;\n",
       "      --fill-color: #1967D2;\n",
       "      --hover-bg-color: #E2EBFA;\n",
       "      --hover-fill-color: #174EA6;\n",
       "      --disabled-fill-color: #AAA;\n",
       "      --disabled-bg-color: #DDD;\n",
       "  }\n",
       "\n",
       "  [theme=dark] .colab-df-quickchart {\n",
       "      --bg-color: #3B4455;\n",
       "      --fill-color: #D2E3FC;\n",
       "      --hover-bg-color: #434B5C;\n",
       "      --hover-fill-color: #FFFFFF;\n",
       "      --disabled-bg-color: #3B4455;\n",
       "      --disabled-fill-color: #666;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart {\n",
       "    background-color: var(--bg-color);\n",
       "    border: none;\n",
       "    border-radius: 50%;\n",
       "    cursor: pointer;\n",
       "    display: none;\n",
       "    fill: var(--fill-color);\n",
       "    height: 32px;\n",
       "    padding: 0;\n",
       "    width: 32px;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart:hover {\n",
       "    background-color: var(--hover-bg-color);\n",
       "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "    fill: var(--button-hover-fill-color);\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart-complete:disabled,\n",
       "  .colab-df-quickchart-complete:disabled:hover {\n",
       "    background-color: var(--disabled-bg-color);\n",
       "    fill: var(--disabled-fill-color);\n",
       "    box-shadow: none;\n",
       "  }\n",
       "\n",
       "  .colab-df-spinner {\n",
       "    border: 2px solid var(--fill-color);\n",
       "    border-color: transparent;\n",
       "    border-bottom-color: var(--fill-color);\n",
       "    animation:\n",
       "      spin 1s steps(1) infinite;\n",
       "  }\n",
       "\n",
       "  @keyframes spin {\n",
       "    0% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "      border-left-color: var(--fill-color);\n",
       "    }\n",
       "    20% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    30% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    40% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    60% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    80% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "    90% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "  }\n",
       "</style>\n",
       "\n",
       "  <script>\n",
       "    async function quickchart(key) {\n",
       "      const quickchartButtonEl =\n",
       "        document.querySelector('#' + key + ' button');\n",
       "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
       "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
       "      try {\n",
       "        const charts = await google.colab.kernel.invokeFunction(\n",
       "            'suggestCharts', [key], {});\n",
       "      } catch (error) {\n",
       "        console.error('Error during call to suggestCharts:', error);\n",
       "      }\n",
       "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
       "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
       "    }\n",
       "    (() => {\n",
       "      let quickchartButtonEl =\n",
       "        document.querySelector('#df-903b4e1f-a7f2-420a-986d-a4431648bd9f button');\n",
       "      quickchartButtonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "    })();\n",
       "  </script>\n",
       "</div>\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "                                                  text         y\n",
       "0    title edit 56dd brend ambasittur for vidya sec...  negative\n",
       "1    this reminds kunkka old dota loading screen ar...  positive\n",
       "2           meanwhile the other news cms intenttarget   negative\n",
       "3                           lovely finish there giroud  positive\n",
       "4    glad see kurisu made with surprising results d...  positive\n",
       "..                                                 ...       ...\n",
       "595   true india needs top universities and not fdi...  positive\n",
       "596                   why did miyaichi come off early   positive\n",
       "597  indian media has lost its credibility now ital...  negative\n",
       "598  malaysia french satellite find further debris ...  negative\n",
       "599  tell many people you can vote for modi this go...  positive\n",
       "\n",
       "[600 rows x 2 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "train_path = '/content/Reddit_Data.csv'\n",
    "\n",
    "train_df = pd.read_csv(train_path)\n",
    "# the text data to use for classification should be in a column named 'text'\n",
    "columns=['text','y']\n",
    "train_df = train_df[columns]\n",
    "train_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "0296Om2C5anY"
   },
   "source": [
    "# 3. Train Deep Learning Classifier using nlu.load('train.sentiment')\n",
    "\n",
    "You dataset label column should be named 'y' and the feature column with text data should be named 'text'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 1000
    },
    "id": "3ZIPkRkWftBG",
    "outputId": "7896942b-7b84-4b21-ee47-a3c59de61166"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning::Spark Session already created, some configs may not take.\n",
      "sent_small_bert_L2_128 download started this may take some time.\n",
      "Approximate size to download 16.1 MB\n",
      "[OK!]\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "    negative       0.00      0.00      0.00        20\n",
      "    positive       0.60      1.00      0.75        30\n",
      "\n",
      "    accuracy                           0.60        50\n",
      "   macro avg       0.30      0.50      0.37        50\n",
      "weighted avg       0.36      0.60      0.45        50\n",
      "\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "  <div id=\"df-315f9a58-2b10-4ff7-bb8e-8526a250ed47\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>document</th>\n",
       "      <th>sentence_embedding_small_bert_L2_128</th>\n",
       "      <th>sentiment</th>\n",
       "      <th>sentiment_confidence</th>\n",
       "      <th>text</th>\n",
       "      <th>y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>title edit 56dd brend ambasittur for vidya secret</td>\n",
       "      <td>[-0.13924618065357208, 0.03819392994046211, -0...</td>\n",
       "      <td>positive</td>\n",
       "      <td>2.0</td>\n",
       "      <td>title edit 56dd brend ambasittur for vidya sec...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>this reminds kunkka old dota loading screen ar...</td>\n",
       "      <td>[-0.05514780059456825, -0.02986345998942852, -...</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>this reminds kunkka old dota loading screen ar...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>meanwhile the other news cms intenttarget</td>\n",
       "      <td>[-1.3784979581832886, -0.05633991211652756, 0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>7.0</td>\n",
       "      <td>meanwhile the other news cms intenttarget</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>lovely finish there giroud</td>\n",
       "      <td>[-1.026403546333313, -0.5962088108062744, -0.5...</td>\n",
       "      <td>positive</td>\n",
       "      <td>4.0</td>\n",
       "      <td>lovely finish there giroud</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>glad see kurisu made with surprising results d...</td>\n",
       "      <td>[-1.3281804323196411, -0.3425588011741638, 0.2...</td>\n",
       "      <td>positive</td>\n",
       "      <td>2.0</td>\n",
       "      <td>glad see kurisu made with surprising results d...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>wee jas lawful neutral god death magic and nec...</td>\n",
       "      <td>[-1.090584635734558, -0.39823225140571594, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>9.0</td>\n",
       "      <td>wee jas lawful neutral god death magic and nec...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>holy fuck this amazing</td>\n",
       "      <td>[-2.318075656890869, -0.10535052418708801, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>7.0</td>\n",
       "      <td>holy fuck this amazing</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>yougaiz yougaiz who interested parineeti chopr...</td>\n",
       "      <td>[-0.7263230085372925, -0.9229655861854553, 0.1...</td>\n",
       "      <td>positive</td>\n",
       "      <td>9.0</td>\n",
       "      <td>yougaiz yougaiz who interested parineeti chopr...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>not whole lot has changed except the fact that...</td>\n",
       "      <td>[-1.1650828123092651, 0.09717072546482086, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>8.0</td>\n",
       "      <td>not whole lot has changed except the fact that...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>different times different cultures same point ...</td>\n",
       "      <td>[-1.5615334510803223, -0.6228992938995361, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>3.0</td>\n",
       "      <td>different times different cultures same point ...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>too much attention</td>\n",
       "      <td>[-1.473575234413147, 0.6288167834281921, -0.68...</td>\n",
       "      <td>positive</td>\n",
       "      <td>3.0</td>\n",
       "      <td>too much attention</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>its nice and all but your monitors make want b...</td>\n",
       "      <td>[-0.8991073966026306, 0.8156149983406067, -0.2...</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>its nice and all but your monitors make want b...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>india turns into toi comments section the mome...</td>\n",
       "      <td>[-0.7343364357948303, -0.12650255858898163, 0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>3.0</td>\n",
       "      <td>india turns into toi comments section the mom...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>nice build man pretty damn sexy can ask why ti...</td>\n",
       "      <td>[-1.21924889087677, 0.21342627704143524, -0.40...</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>nice build man pretty damn sexy can ask why ti...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>rofl why are you asking permission you and you...</td>\n",
       "      <td>[-0.8997104167938232, 0.45302870869636536, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>7.0</td>\n",
       "      <td>rofl why are you asking permission you and you...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>seriously did you infographic maker even consi...</td>\n",
       "      <td>[-0.8621772527694702, 0.4609760046005249, -0.1...</td>\n",
       "      <td>positive</td>\n",
       "      <td>2.0</td>\n",
       "      <td>seriously did you infographic maker even consi...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>cliche but you can wrong with cyric mean was m...</td>\n",
       "      <td>[-1.3570650815963745, -0.10502084344625473, -0...</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>cliche but you can wrong with cyric mean was ...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>from whatever heard this the model modi speech...</td>\n",
       "      <td>[-0.8209349513053894, 0.2195633053779602, -0.2...</td>\n",
       "      <td>positive</td>\n",
       "      <td>2.0</td>\n",
       "      <td>from whatever heard this the model modi speech...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>heard there was direct line narendra modi whic...</td>\n",
       "      <td>[-0.4502873718738556, -0.10798719525337219, -0...</td>\n",
       "      <td>positive</td>\n",
       "      <td>3.0</td>\n",
       "      <td>heard there was direct line narendra modi whi...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>truth told there not insignificant percentage ...</td>\n",
       "      <td>[-0.6922494173049927, 0.08739931136369705, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>8.0</td>\n",
       "      <td>truth told there not insignificant percentage ...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>many them fear namo being prime minister could...</td>\n",
       "      <td>[-1.3202203512191772, -0.021619228646159172, -...</td>\n",
       "      <td>positive</td>\n",
       "      <td>2.0</td>\n",
       "      <td>many them fear namo being prime minister coul...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>source will have accommodate hindus from bangl...</td>\n",
       "      <td>[-0.6071749329566956, 0.21432138979434967, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>source will have accommodate hindus from bang...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>confirmed woman and this india 186 comments le...</td>\n",
       "      <td>[-0.7401843070983887, -0.4919162094593048, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>3.0</td>\n",
       "      <td>confirmed woman and this india 186 comments l...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>prepared for downvotes but after watching seve...</td>\n",
       "      <td>[-0.5390527844429016, 1.0651843547821045, -0.5...</td>\n",
       "      <td>positive</td>\n",
       "      <td>2.0</td>\n",
       "      <td>prepared for downvotes but after watching sev...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>delhi not sleeping after long day see congress...</td>\n",
       "      <td>[-1.3164680004119873, 0.059689976274967194, -0...</td>\n",
       "      <td>positive</td>\n",
       "      <td>4.0</td>\n",
       "      <td>delhi not sleeping after long day see congres...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>would like bjp come out support scrapping sec ...</td>\n",
       "      <td>[-0.39008525013923645, 0.6130499243736267, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>2.0</td>\n",
       "      <td>would like bjp come out support scrapping sec...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>update still found debris black boxes evidence...</td>\n",
       "      <td>[-0.5251181721687317, 0.5843355059623718, -0.2...</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>update still found debris black boxes evidenc...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>there one tool bjp can use their manifesto whi...</td>\n",
       "      <td>[-0.42395493388175964, 0.3328923285007477, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>2.0</td>\n",
       "      <td>there one tool bjp can use their manifesto whi...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>wtf why</td>\n",
       "      <td>[-1.0021588802337646, 1.2250791788101196, 0.05...</td>\n",
       "      <td>positive</td>\n",
       "      <td>4.0</td>\n",
       "      <td>wtf why</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>fantastic strike the</td>\n",
       "      <td>[-0.6758270859718323, -0.2134172022342682, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>2.0</td>\n",
       "      <td>fantastic strike the</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>you mean the ruling coalition government hatch...</td>\n",
       "      <td>[-0.5493559837341309, -0.2645500600337982, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>you mean the ruling coalition government hatch...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>before used anti rss result anti bjp very skep...</td>\n",
       "      <td>[-0.11697939038276672, 0.26724380254745483, 0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>7.0</td>\n",
       "      <td>before used anti rss result anti bjp very ske...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>first understand that you are not anyway contr...</td>\n",
       "      <td>[-1.1990007162094116, -0.23811395466327667, -0...</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>first understand that you are not anyway contr...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>personally for shooting muslims and internetof...</td>\n",
       "      <td>[-1.314710259437561, -0.07083063572645187, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>8.0</td>\n",
       "      <td>personally for shooting muslims and internetof...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>nice build one thing caught eye absolute splur...</td>\n",
       "      <td>[-0.3646998703479767, -0.6708006262779236, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>8.0</td>\n",
       "      <td>nice build one thing caught eye absolute splur...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>looks shit now but still proud made</td>\n",
       "      <td>[-1.128523588180542, 0.31619158387184143, 0.02...</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>looks shit now but still proud made</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>what wrong with that another lame ass attempt ...</td>\n",
       "      <td>[-1.9695912599563599, 0.27932408452033997, 0.0...</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>what wrong with that another lame ass attempt ...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>how difficult was get the length and bend the ...</td>\n",
       "      <td>[-1.2320657968521118, 0.9790331721305847, -0.5...</td>\n",
       "      <td>positive</td>\n",
       "      <td>8.0</td>\n",
       "      <td>how difficult was get the length and bend the ...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>very impressed with gnabry movement and linkin...</td>\n",
       "      <td>[-0.3107994794845581, 0.3307916522026062, -0.1...</td>\n",
       "      <td>positive</td>\n",
       "      <td>4.0</td>\n",
       "      <td>very impressed with gnabry movement and linki...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>here interesting tidbit what the like off pert...</td>\n",
       "      <td>[-0.308876633644104, 0.49783819913864136, -0.2...</td>\n",
       "      <td>positive</td>\n",
       "      <td>2.0</td>\n",
       "      <td>here interesting tidbit what the like off pert...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>false dichotomy either you are for for bjp you...</td>\n",
       "      <td>[-0.6038466691970825, 0.2866456210613251, -0.3...</td>\n",
       "      <td>positive</td>\n",
       "      <td>3.0</td>\n",
       "      <td>false dichotomy either you are for for bjp you...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>angry namo bhaktas the survival the angry namo...</td>\n",
       "      <td>[-1.20363450050354, -1.119809627532959, -0.183...</td>\n",
       "      <td>positive</td>\n",
       "      <td>4.0</td>\n",
       "      <td>angry namo bhaktas the survival the angry namo...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>this would issue these people were prosecuted ...</td>\n",
       "      <td>[-0.853580892086029, 0.8160178661346436, 0.117...</td>\n",
       "      <td>positive</td>\n",
       "      <td>4.0</td>\n",
       "      <td>this would issue these people were prosecuted ...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>hate free india would boring love hate relatio...</td>\n",
       "      <td>[-0.28927552700042725, -0.9648609757423401, -0...</td>\n",
       "      <td>positive</td>\n",
       "      <td>2.0</td>\n",
       "      <td>hate free india would boring love hate relati...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>this getting bit silly now</td>\n",
       "      <td>[-1.1343425512313843, -0.030997686088085175, 0...</td>\n",
       "      <td>positive</td>\n",
       "      <td>5.0</td>\n",
       "      <td>this getting bit silly now</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>giroud should done better but great ball rosicky</td>\n",
       "      <td>[-1.308074951171875, -0.03950951248407364, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>3.0</td>\n",
       "      <td>giroud should done better but great ball rosicky</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>jakiro spotted the middle top maybe</td>\n",
       "      <td>[-2.2450177669525146, -0.5104915499687195, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>2.0</td>\n",
       "      <td>jakiro spotted the middle top maybe</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>won vote for aap anymore that for sure though ...</td>\n",
       "      <td>[-0.7843935489654541, -0.32822510600090027, 0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>5.0</td>\n",
       "      <td>won vote for aap anymore that for sure though...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>regardless the opposition all girouds goals ha...</td>\n",
       "      <td>[-1.635783076286316, 0.30238792300224304, -0.7...</td>\n",
       "      <td>positive</td>\n",
       "      <td>2.0</td>\n",
       "      <td>regardless the opposition all girouds goals ha...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>directly pleading people who oppose modi just ...</td>\n",
       "      <td>[-0.7491450905799866, -0.4327720105648041, 0.0...</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>directly pleading people who oppose modi just...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-315f9a58-2b10-4ff7-bb8e-8526a250ed47')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-315f9a58-2b10-4ff7-bb8e-8526a250ed47 button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-315f9a58-2b10-4ff7-bb8e-8526a250ed47');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "<div id=\"df-9374d6ca-6e45-4f2b-8202-ef2ffd4e9419\">\n",
       "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-9374d6ca-6e45-4f2b-8202-ef2ffd4e9419')\"\n",
       "            title=\"Suggest charts.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "     width=\"24px\">\n",
       "    <g>\n",
       "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
       "    </g>\n",
       "</svg>\n",
       "  </button>\n",
       "\n",
       "<style>\n",
       "  .colab-df-quickchart {\n",
       "      --bg-color: #E8F0FE;\n",
       "      --fill-color: #1967D2;\n",
       "      --hover-bg-color: #E2EBFA;\n",
       "      --hover-fill-color: #174EA6;\n",
       "      --disabled-fill-color: #AAA;\n",
       "      --disabled-bg-color: #DDD;\n",
       "  }\n",
       "\n",
       "  [theme=dark] .colab-df-quickchart {\n",
       "      --bg-color: #3B4455;\n",
       "      --fill-color: #D2E3FC;\n",
       "      --hover-bg-color: #434B5C;\n",
       "      --hover-fill-color: #FFFFFF;\n",
       "      --disabled-bg-color: #3B4455;\n",
       "      --disabled-fill-color: #666;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart {\n",
       "    background-color: var(--bg-color);\n",
       "    border: none;\n",
       "    border-radius: 50%;\n",
       "    cursor: pointer;\n",
       "    display: none;\n",
       "    fill: var(--fill-color);\n",
       "    height: 32px;\n",
       "    padding: 0;\n",
       "    width: 32px;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart:hover {\n",
       "    background-color: var(--hover-bg-color);\n",
       "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "    fill: var(--button-hover-fill-color);\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart-complete:disabled,\n",
       "  .colab-df-quickchart-complete:disabled:hover {\n",
       "    background-color: var(--disabled-bg-color);\n",
       "    fill: var(--disabled-fill-color);\n",
       "    box-shadow: none;\n",
       "  }\n",
       "\n",
       "  .colab-df-spinner {\n",
       "    border: 2px solid var(--fill-color);\n",
       "    border-color: transparent;\n",
       "    border-bottom-color: var(--fill-color);\n",
       "    animation:\n",
       "      spin 1s steps(1) infinite;\n",
       "  }\n",
       "\n",
       "  @keyframes spin {\n",
       "    0% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "      border-left-color: var(--fill-color);\n",
       "    }\n",
       "    20% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    30% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    40% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    60% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    80% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "    90% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "  }\n",
       "</style>\n",
       "\n",
       "  <script>\n",
       "    async function quickchart(key) {\n",
       "      const quickchartButtonEl =\n",
       "        document.querySelector('#' + key + ' button');\n",
       "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
       "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
       "      try {\n",
       "        const charts = await google.colab.kernel.invokeFunction(\n",
       "            'suggestCharts', [key], {});\n",
       "      } catch (error) {\n",
       "        console.error('Error during call to suggestCharts:', error);\n",
       "      }\n",
       "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
       "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
       "    }\n",
       "    (() => {\n",
       "      let quickchartButtonEl =\n",
       "        document.querySelector('#df-9374d6ca-6e45-4f2b-8202-ef2ffd4e9419 button');\n",
       "      quickchartButtonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "    })();\n",
       "  </script>\n",
       "</div>\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "                                             document  \\\n",
       "0   title edit 56dd brend ambasittur for vidya secret   \n",
       "1   this reminds kunkka old dota loading screen ar...   \n",
       "2           meanwhile the other news cms intenttarget   \n",
       "3                          lovely finish there giroud   \n",
       "4   glad see kurisu made with surprising results d...   \n",
       "5   wee jas lawful neutral god death magic and nec...   \n",
       "6                              holy fuck this amazing   \n",
       "7   yougaiz yougaiz who interested parineeti chopr...   \n",
       "8   not whole lot has changed except the fact that...   \n",
       "9   different times different cultures same point ...   \n",
       "10                                 too much attention   \n",
       "11  its nice and all but your monitors make want b...   \n",
       "12  india turns into toi comments section the mome...   \n",
       "13  nice build man pretty damn sexy can ask why ti...   \n",
       "14  rofl why are you asking permission you and you...   \n",
       "15  seriously did you infographic maker even consi...   \n",
       "16  cliche but you can wrong with cyric mean was m...   \n",
       "17  from whatever heard this the model modi speech...   \n",
       "18  heard there was direct line narendra modi whic...   \n",
       "19  truth told there not insignificant percentage ...   \n",
       "20  many them fear namo being prime minister could...   \n",
       "21  source will have accommodate hindus from bangl...   \n",
       "22  confirmed woman and this india 186 comments le...   \n",
       "23  prepared for downvotes but after watching seve...   \n",
       "24  delhi not sleeping after long day see congress...   \n",
       "25  would like bjp come out support scrapping sec ...   \n",
       "26  update still found debris black boxes evidence...   \n",
       "27  there one tool bjp can use their manifesto whi...   \n",
       "28                                            wtf why   \n",
       "29                               fantastic strike the   \n",
       "30  you mean the ruling coalition government hatch...   \n",
       "31  before used anti rss result anti bjp very skep...   \n",
       "32  first understand that you are not anyway contr...   \n",
       "33  personally for shooting muslims and internetof...   \n",
       "34  nice build one thing caught eye absolute splur...   \n",
       "35                looks shit now but still proud made   \n",
       "36  what wrong with that another lame ass attempt ...   \n",
       "37  how difficult was get the length and bend the ...   \n",
       "38  very impressed with gnabry movement and linkin...   \n",
       "39  here interesting tidbit what the like off pert...   \n",
       "40  false dichotomy either you are for for bjp you...   \n",
       "41  angry namo bhaktas the survival the angry namo...   \n",
       "42  this would issue these people were prosecuted ...   \n",
       "43  hate free india would boring love hate relatio...   \n",
       "44                         this getting bit silly now   \n",
       "45   giroud should done better but great ball rosicky   \n",
       "46                jakiro spotted the middle top maybe   \n",
       "47  won vote for aap anymore that for sure though ...   \n",
       "48  regardless the opposition all girouds goals ha...   \n",
       "49  directly pleading people who oppose modi just ...   \n",
       "\n",
       "                 sentence_embedding_small_bert_L2_128 sentiment  \\\n",
       "0   [-0.13924618065357208, 0.03819392994046211, -0...  positive   \n",
       "1   [-0.05514780059456825, -0.02986345998942852, -...  positive   \n",
       "2   [-1.3784979581832886, -0.05633991211652756, 0....  positive   \n",
       "3   [-1.026403546333313, -0.5962088108062744, -0.5...  positive   \n",
       "4   [-1.3281804323196411, -0.3425588011741638, 0.2...  positive   \n",
       "5   [-1.090584635734558, -0.39823225140571594, -0....  positive   \n",
       "6   [-2.318075656890869, -0.10535052418708801, -0....  positive   \n",
       "7   [-0.7263230085372925, -0.9229655861854553, 0.1...  positive   \n",
       "8   [-1.1650828123092651, 0.09717072546482086, -0....  positive   \n",
       "9   [-1.5615334510803223, -0.6228992938995361, -0....  positive   \n",
       "10  [-1.473575234413147, 0.6288167834281921, -0.68...  positive   \n",
       "11  [-0.8991073966026306, 0.8156149983406067, -0.2...  positive   \n",
       "12  [-0.7343364357948303, -0.12650255858898163, 0....  positive   \n",
       "13  [-1.21924889087677, 0.21342627704143524, -0.40...  positive   \n",
       "14  [-0.8997104167938232, 0.45302870869636536, -0....  positive   \n",
       "15  [-0.8621772527694702, 0.4609760046005249, -0.1...  positive   \n",
       "16  [-1.3570650815963745, -0.10502084344625473, -0...  positive   \n",
       "17  [-0.8209349513053894, 0.2195633053779602, -0.2...  positive   \n",
       "18  [-0.4502873718738556, -0.10798719525337219, -0...  positive   \n",
       "19  [-0.6922494173049927, 0.08739931136369705, -0....  positive   \n",
       "20  [-1.3202203512191772, -0.021619228646159172, -...  positive   \n",
       "21  [-0.6071749329566956, 0.21432138979434967, -0....  positive   \n",
       "22  [-0.7401843070983887, -0.4919162094593048, -0....  positive   \n",
       "23  [-0.5390527844429016, 1.0651843547821045, -0.5...  positive   \n",
       "24  [-1.3164680004119873, 0.059689976274967194, -0...  positive   \n",
       "25  [-0.39008525013923645, 0.6130499243736267, -0....  positive   \n",
       "26  [-0.5251181721687317, 0.5843355059623718, -0.2...  positive   \n",
       "27  [-0.42395493388175964, 0.3328923285007477, -0....  positive   \n",
       "28  [-1.0021588802337646, 1.2250791788101196, 0.05...  positive   \n",
       "29  [-0.6758270859718323, -0.2134172022342682, -0....  positive   \n",
       "30  [-0.5493559837341309, -0.2645500600337982, -0....  positive   \n",
       "31  [-0.11697939038276672, 0.26724380254745483, 0....  positive   \n",
       "32  [-1.1990007162094116, -0.23811395466327667, -0...  positive   \n",
       "33  [-1.314710259437561, -0.07083063572645187, -0....  positive   \n",
       "34  [-0.3646998703479767, -0.6708006262779236, -0....  positive   \n",
       "35  [-1.128523588180542, 0.31619158387184143, 0.02...  positive   \n",
       "36  [-1.9695912599563599, 0.27932408452033997, 0.0...  positive   \n",
       "37  [-1.2320657968521118, 0.9790331721305847, -0.5...  positive   \n",
       "38  [-0.3107994794845581, 0.3307916522026062, -0.1...  positive   \n",
       "39  [-0.308876633644104, 0.49783819913864136, -0.2...  positive   \n",
       "40  [-0.6038466691970825, 0.2866456210613251, -0.3...  positive   \n",
       "41  [-1.20363450050354, -1.119809627532959, -0.183...  positive   \n",
       "42  [-0.853580892086029, 0.8160178661346436, 0.117...  positive   \n",
       "43  [-0.28927552700042725, -0.9648609757423401, -0...  positive   \n",
       "44  [-1.1343425512313843, -0.030997686088085175, 0...  positive   \n",
       "45  [-1.308074951171875, -0.03950951248407364, -0....  positive   \n",
       "46  [-2.2450177669525146, -0.5104915499687195, -0....  positive   \n",
       "47  [-0.7843935489654541, -0.32822510600090027, 0....  positive   \n",
       "48  [-1.635783076286316, 0.30238792300224304, -0.7...  positive   \n",
       "49  [-0.7491450905799866, -0.4327720105648041, 0.0...  positive   \n",
       "\n",
       "   sentiment_confidence                                               text  \\\n",
       "0                   2.0  title edit 56dd brend ambasittur for vidya sec...   \n",
       "1                   1.0  this reminds kunkka old dota loading screen ar...   \n",
       "2                   7.0         meanwhile the other news cms intenttarget    \n",
       "3                   4.0                         lovely finish there giroud   \n",
       "4                   2.0  glad see kurisu made with surprising results d...   \n",
       "5                   9.0  wee jas lawful neutral god death magic and nec...   \n",
       "6                   7.0                            holy fuck this amazing    \n",
       "7                   9.0  yougaiz yougaiz who interested parineeti chopr...   \n",
       "8                   8.0  not whole lot has changed except the fact that...   \n",
       "9                   3.0  different times different cultures same point ...   \n",
       "10                  3.0                                too much attention    \n",
       "11                  1.0  its nice and all but your monitors make want b...   \n",
       "12                  3.0   india turns into toi comments section the mom...   \n",
       "13                  1.0  nice build man pretty damn sexy can ask why ti...   \n",
       "14                  7.0  rofl why are you asking permission you and you...   \n",
       "15                  2.0  seriously did you infographic maker even consi...   \n",
       "16                  1.0   cliche but you can wrong with cyric mean was ...   \n",
       "17                  2.0  from whatever heard this the model modi speech...   \n",
       "18                  3.0   heard there was direct line narendra modi whi...   \n",
       "19                  8.0  truth told there not insignificant percentage ...   \n",
       "20                  2.0   many them fear namo being prime minister coul...   \n",
       "21                  1.0   source will have accommodate hindus from bang...   \n",
       "22                  3.0   confirmed woman and this india 186 comments l...   \n",
       "23                  2.0   prepared for downvotes but after watching sev...   \n",
       "24                  4.0   delhi not sleeping after long day see congres...   \n",
       "25                  2.0   would like bjp come out support scrapping sec...   \n",
       "26                  1.0   update still found debris black boxes evidenc...   \n",
       "27                  2.0  there one tool bjp can use their manifesto whi...   \n",
       "28                  4.0                                           wtf why    \n",
       "29                  2.0                              fantastic strike the    \n",
       "30                  1.0  you mean the ruling coalition government hatch...   \n",
       "31                  7.0   before used anti rss result anti bjp very ske...   \n",
       "32                  1.0  first understand that you are not anyway contr...   \n",
       "33                  8.0  personally for shooting muslims and internetof...   \n",
       "34                  8.0  nice build one thing caught eye absolute splur...   \n",
       "35                  1.0               looks shit now but still proud made    \n",
       "36                  1.0  what wrong with that another lame ass attempt ...   \n",
       "37                  8.0  how difficult was get the length and bend the ...   \n",
       "38                  4.0   very impressed with gnabry movement and linki...   \n",
       "39                  2.0  here interesting tidbit what the like off pert...   \n",
       "40                  3.0  false dichotomy either you are for for bjp you...   \n",
       "41                  4.0  angry namo bhaktas the survival the angry namo...   \n",
       "42                  4.0  this would issue these people were prosecuted ...   \n",
       "43                  2.0   hate free india would boring love hate relati...   \n",
       "44                  5.0                        this getting bit silly now    \n",
       "45                  3.0  giroud should done better but great ball rosicky    \n",
       "46                  2.0               jakiro spotted the middle top maybe    \n",
       "47                  5.0   won vote for aap anymore that for sure though...   \n",
       "48                  2.0  regardless the opposition all girouds goals ha...   \n",
       "49                  1.0   directly pleading people who oppose modi just...   \n",
       "\n",
       "           y  \n",
       "0   negative  \n",
       "1   positive  \n",
       "2   negative  \n",
       "3   positive  \n",
       "4   positive  \n",
       "5   positive  \n",
       "6   positive  \n",
       "7   positive  \n",
       "8   positive  \n",
       "9   positive  \n",
       "10  positive  \n",
       "11  positive  \n",
       "12  positive  \n",
       "13  positive  \n",
       "14  positive  \n",
       "15  negative  \n",
       "16  negative  \n",
       "17  positive  \n",
       "18  positive  \n",
       "19  positive  \n",
       "20  positive  \n",
       "21  negative  \n",
       "22  positive  \n",
       "23  negative  \n",
       "24  negative  \n",
       "25  negative  \n",
       "26  negative  \n",
       "27  positive  \n",
       "28  negative  \n",
       "29  positive  \n",
       "30  negative  \n",
       "31  positive  \n",
       "32  positive  \n",
       "33  negative  \n",
       "34  positive  \n",
       "35  positive  \n",
       "36  negative  \n",
       "37  positive  \n",
       "38  positive  \n",
       "39  negative  \n",
       "40  negative  \n",
       "41  negative  \n",
       "42  negative  \n",
       "43  negative  \n",
       "44  negative  \n",
       "45  positive  \n",
       "46  positive  \n",
       "47  negative  \n",
       "48  positive  \n",
       "49  positive  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.metrics import classification_report\n",
    "from johnsnowlabs import nlp\n",
    "# load a trainable pipeline by specifying the train. prefix  and fit it on a datset with label and text columns\n",
    "# by default the Universal Sentence Encoder (USE) Sentence embeddings are used for generation\n",
    "trainable_pipe = nlp.load('train.sentiment')\n",
    "fitted_pipe = trainable_pipe.fit(train_df.iloc[:50])\n",
    "\n",
    "# predict with the trainable pipeline on dataset and get predictions\n",
    "preds = fitted_pipe.predict(train_df.iloc[:50],output_level='document')\n",
    "#sentence detector that is part of the pipe generates sone NaNs. lets drop them first\n",
    "preds.dropna(inplace=True)\n",
    "print(classification_report(preds['y'], preds['sentiment']))\n",
    "\n",
    "preds"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "lVyOE2wV0fw_"
   },
   "source": [
    "# Test the fitted pipe on new example"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 150
    },
    "id": "qdCUg2MR0PD2",
    "outputId": "ea8e288d-2016-4777-99f5-9dd729a25e3f"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "sentence_detector_dl download started this may take some time.\n",
      "Approximate size to download 354.6 KB\n",
      "[OK!]\n",
      "Warning::Spark Session already created, some configs may not take.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "  <div id=\"df-ed7db038-4a99-4bd8-b2e3-daadcc437196\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sentence</th>\n",
       "      <th>sentence_embedding_small_bert_L2_128</th>\n",
       "      <th>sentiment</th>\n",
       "      <th>sentiment_confidence</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Indian prime minister was assinated!</td>\n",
       "      <td>[-0.7613918781280518, 0.7001779079437256, -0.1...</td>\n",
       "      <td>positive</td>\n",
       "      <td>0.999982</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-ed7db038-4a99-4bd8-b2e3-daadcc437196')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-ed7db038-4a99-4bd8-b2e3-daadcc437196 button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-ed7db038-4a99-4bd8-b2e3-daadcc437196');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "                               sentence  \\\n",
       "0  Indian prime minister was assinated!   \n",
       "\n",
       "                sentence_embedding_small_bert_L2_128 sentiment  \\\n",
       "0  [-0.7613918781280518, 0.7001779079437256, -0.1...  positive   \n",
       "\n",
       "  sentiment_confidence  \n",
       "0             0.999982  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fitted_pipe.predict(\"Indian prime minister was assinated!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "xflpwrVjjBVD"
   },
   "source": [
    "## Configure pipe training parameters"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "UtsAUGTmOTms",
    "outputId": "12c0a69d-9fbc-41de-9de3-f923097e9b54"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The following parameters are configurable for this NLU pipeline (You can copy paste the examples) :\n",
      ">>> component_list['bert_sentence_embeddings@sent_small_bert_L2_128'] has settable params:\n",
      "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setBatchSize(8)              | Info: Size of every batch | Currently set to : 8\n",
      "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setEngine('tensorflow')      | Info: Deep Learning engine used for this model | Currently set to : tensorflow\n",
      "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setIsLong(False)             | Info: Use Long type instead of Int type for inputs buffer - Some Bert models require Long instead of Int. | Currently set to : False\n",
      "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setMaxSentenceLength(128)    | Info: Max sentence length to process | Currently set to : 128\n",
      "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setDimension(128)            | Info: Number of embedding dimensions | Currently set to : 128\n",
      "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setCaseSensitive(False)      | Info: whether to ignore case in tokens for embeddings matching | Currently set to : False\n",
      "component_list['bert_sentence_embeddings@sent_small_bert_L2_128'].setStorageRef('sent_small_bert_L2_128')  | Info: unique reference name for identification | Currently set to : sent_small_bert_L2_128\n",
      ">>> component_list['document_assembler'] has settable params:\n",
      "component_list['document_assembler'].setCleanupMode('shrink')                                  | Info: possible values: disabled, inplace, inplace_full, shrink, shrink_full, each, each_full, delete_full | Currently set to : shrink\n",
      ">>> component_list['sentiment_dl@sent_small_bert_L2_128'] has settable params:\n",
      "component_list['sentiment_dl@sent_small_bert_L2_128'].setEngine('tensorflow')                  | Info: Deep Learning engine used for this model | Currently set to : tensorflow\n",
      "component_list['sentiment_dl@sent_small_bert_L2_128'].setThreshold(0.6)                        | Info: The minimum threshold for the final result otheriwse it will be neutral | Currently set to : 0.6\n",
      "component_list['sentiment_dl@sent_small_bert_L2_128'].setThresholdLabel('neutral')             | Info: In case the score is less than threshold, what should be the label. Default is neutral. | Currently set to : neutral\n",
      "component_list['sentiment_dl@sent_small_bert_L2_128'].setStorageRef('sent_small_bert_L2_128')  | Info: unique reference name for identification | Currently set to : sent_small_bert_L2_128\n"
     ]
    }
   ],
   "source": [
    "trainable_pipe.print_info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "2GJdDNV9jEIe"
   },
   "source": [
    "## Retrain with new parameters"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 1000
    },
    "id": "mptfvHx-MMMX",
    "outputId": "0905f3b3-babb-401a-f027-eb2e8475da37"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning::Spark Session already created, some configs may not take.\n",
      "Warning::Spark Session already created, some configs may not take.\n",
      "sent_small_bert_L2_128 download started this may take some time.\n",
      "Approximate size to download 16.1 MB\n",
      "[OK!]\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "    negative       0.00      0.00      0.00        20\n",
      "    positive       0.60      1.00      0.75        30\n",
      "\n",
      "    accuracy                           0.60        50\n",
      "   macro avg       0.30      0.50      0.37        50\n",
      "weighted avg       0.36      0.60      0.45        50\n",
      "\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "  <div id=\"df-96a9eb02-4e31-433b-b84a-e11316f770e7\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>document</th>\n",
       "      <th>sentence_embedding_small_bert_L2_128</th>\n",
       "      <th>sentiment</th>\n",
       "      <th>sentiment_confidence</th>\n",
       "      <th>text</th>\n",
       "      <th>y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>title edit 56dd brend ambasittur for vidya secret</td>\n",
       "      <td>[-0.13924618065357208, 0.03819392994046211, -0...</td>\n",
       "      <td>positive</td>\n",
       "      <td>2.0</td>\n",
       "      <td>title edit 56dd brend ambasittur for vidya sec...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>this reminds kunkka old dota loading screen ar...</td>\n",
       "      <td>[-0.05514780059456825, -0.02986345998942852, -...</td>\n",
       "      <td>positive</td>\n",
       "      <td>2.0</td>\n",
       "      <td>this reminds kunkka old dota loading screen ar...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>meanwhile the other news cms intenttarget</td>\n",
       "      <td>[-1.3784979581832886, -0.05633991211652756, 0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>4.0</td>\n",
       "      <td>meanwhile the other news cms intenttarget</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>lovely finish there giroud</td>\n",
       "      <td>[-1.026403546333313, -0.5962088108062744, -0.5...</td>\n",
       "      <td>positive</td>\n",
       "      <td>9.0</td>\n",
       "      <td>lovely finish there giroud</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>glad see kurisu made with surprising results d...</td>\n",
       "      <td>[-1.3281804323196411, -0.3425588011741638, 0.2...</td>\n",
       "      <td>positive</td>\n",
       "      <td>4.0</td>\n",
       "      <td>glad see kurisu made with surprising results d...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>wee jas lawful neutral god death magic and nec...</td>\n",
       "      <td>[-1.090584635734558, -0.39823225140571594, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>4.0</td>\n",
       "      <td>wee jas lawful neutral god death magic and nec...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>holy fuck this amazing</td>\n",
       "      <td>[-2.318075656890869, -0.10535052418708801, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>2.0</td>\n",
       "      <td>holy fuck this amazing</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>yougaiz yougaiz who interested parineeti chopr...</td>\n",
       "      <td>[-0.7263230085372925, -0.9229655861854553, 0.1...</td>\n",
       "      <td>positive</td>\n",
       "      <td>2.0</td>\n",
       "      <td>yougaiz yougaiz who interested parineeti chopr...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>not whole lot has changed except the fact that...</td>\n",
       "      <td>[-1.1650828123092651, 0.09717072546482086, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>3.0</td>\n",
       "      <td>not whole lot has changed except the fact that...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>different times different cultures same point ...</td>\n",
       "      <td>[-1.5615334510803223, -0.6228992938995361, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>different times different cultures same point ...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>too much attention</td>\n",
       "      <td>[-1.473575234413147, 0.6288167834281921, -0.68...</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>too much attention</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>its nice and all but your monitors make want b...</td>\n",
       "      <td>[-0.8991073966026306, 0.8156149983406067, -0.2...</td>\n",
       "      <td>positive</td>\n",
       "      <td>3.0</td>\n",
       "      <td>its nice and all but your monitors make want b...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>india turns into toi comments section the mome...</td>\n",
       "      <td>[-0.7343364357948303, -0.12650255858898163, 0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>india turns into toi comments section the mom...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>nice build man pretty damn sexy can ask why ti...</td>\n",
       "      <td>[-1.21924889087677, 0.21342627704143524, -0.40...</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>nice build man pretty damn sexy can ask why ti...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>rofl why are you asking permission you and you...</td>\n",
       "      <td>[-0.8997104167938232, 0.45302870869636536, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>rofl why are you asking permission you and you...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>seriously did you infographic maker even consi...</td>\n",
       "      <td>[-0.8621772527694702, 0.4609760046005249, -0.1...</td>\n",
       "      <td>positive</td>\n",
       "      <td>2.0</td>\n",
       "      <td>seriously did you infographic maker even consi...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>cliche but you can wrong with cyric mean was m...</td>\n",
       "      <td>[-1.3570650815963745, -0.10502084344625473, -0...</td>\n",
       "      <td>positive</td>\n",
       "      <td>3.0</td>\n",
       "      <td>cliche but you can wrong with cyric mean was ...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>from whatever heard this the model modi speech...</td>\n",
       "      <td>[-0.8209349513053894, 0.2195633053779602, -0.2...</td>\n",
       "      <td>positive</td>\n",
       "      <td>6.0</td>\n",
       "      <td>from whatever heard this the model modi speech...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>heard there was direct line narendra modi whic...</td>\n",
       "      <td>[-0.4502873718738556, -0.10798719525337219, -0...</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>heard there was direct line narendra modi whi...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>truth told there not insignificant percentage ...</td>\n",
       "      <td>[-0.6922494173049927, 0.08739931136369705, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>truth told there not insignificant percentage ...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>many them fear namo being prime minister could...</td>\n",
       "      <td>[-1.3202203512191772, -0.021619228646159172, -...</td>\n",
       "      <td>positive</td>\n",
       "      <td>7.0</td>\n",
       "      <td>many them fear namo being prime minister coul...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>source will have accommodate hindus from bangl...</td>\n",
       "      <td>[-0.6071749329566956, 0.21432138979434967, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>4.0</td>\n",
       "      <td>source will have accommodate hindus from bang...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>confirmed woman and this india 186 comments le...</td>\n",
       "      <td>[-0.7401843070983887, -0.4919162094593048, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>confirmed woman and this india 186 comments l...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>prepared for downvotes but after watching seve...</td>\n",
       "      <td>[-0.5390527844429016, 1.0651843547821045, -0.5...</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>prepared for downvotes but after watching sev...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>delhi not sleeping after long day see congress...</td>\n",
       "      <td>[-1.3164680004119873, 0.059689976274967194, -0...</td>\n",
       "      <td>positive</td>\n",
       "      <td>7.0</td>\n",
       "      <td>delhi not sleeping after long day see congres...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>would like bjp come out support scrapping sec ...</td>\n",
       "      <td>[-0.39008525013923645, 0.6130499243736267, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>would like bjp come out support scrapping sec...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>update still found debris black boxes evidence...</td>\n",
       "      <td>[-0.5251181721687317, 0.5843355059623718, -0.2...</td>\n",
       "      <td>positive</td>\n",
       "      <td>4.0</td>\n",
       "      <td>update still found debris black boxes evidenc...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>there one tool bjp can use their manifesto whi...</td>\n",
       "      <td>[-0.42395493388175964, 0.3328923285007477, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>3.0</td>\n",
       "      <td>there one tool bjp can use their manifesto whi...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>wtf why</td>\n",
       "      <td>[-1.0021588802337646, 1.2250791788101196, 0.05...</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>wtf why</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>fantastic strike the</td>\n",
       "      <td>[-0.6758270859718323, -0.2134172022342682, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>2.0</td>\n",
       "      <td>fantastic strike the</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>you mean the ruling coalition government hatch...</td>\n",
       "      <td>[-0.5493559837341309, -0.2645500600337982, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>2.0</td>\n",
       "      <td>you mean the ruling coalition government hatch...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>before used anti rss result anti bjp very skep...</td>\n",
       "      <td>[-0.11697939038276672, 0.26724380254745483, 0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>before used anti rss result anti bjp very ske...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>first understand that you are not anyway contr...</td>\n",
       "      <td>[-1.1990007162094116, -0.23811395466327667, -0...</td>\n",
       "      <td>positive</td>\n",
       "      <td>7.0</td>\n",
       "      <td>first understand that you are not anyway contr...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>personally for shooting muslims and internetof...</td>\n",
       "      <td>[-1.314710259437561, -0.07083063572645187, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>5.0</td>\n",
       "      <td>personally for shooting muslims and internetof...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>nice build one thing caught eye absolute splur...</td>\n",
       "      <td>[-0.3646998703479767, -0.6708006262779236, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>4.0</td>\n",
       "      <td>nice build one thing caught eye absolute splur...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>looks shit now but still proud made</td>\n",
       "      <td>[-1.128523588180542, 0.31619158387184143, 0.02...</td>\n",
       "      <td>positive</td>\n",
       "      <td>4.0</td>\n",
       "      <td>looks shit now but still proud made</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>what wrong with that another lame ass attempt ...</td>\n",
       "      <td>[-1.9695912599563599, 0.27932408452033997, 0.0...</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>what wrong with that another lame ass attempt ...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>how difficult was get the length and bend the ...</td>\n",
       "      <td>[-1.2320657968521118, 0.9790331721305847, -0.5...</td>\n",
       "      <td>positive</td>\n",
       "      <td>4.0</td>\n",
       "      <td>how difficult was get the length and bend the ...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>very impressed with gnabry movement and linkin...</td>\n",
       "      <td>[-0.3107994794845581, 0.3307916522026062, -0.1...</td>\n",
       "      <td>positive</td>\n",
       "      <td>5.0</td>\n",
       "      <td>very impressed with gnabry movement and linki...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>here interesting tidbit what the like off pert...</td>\n",
       "      <td>[-0.308876633644104, 0.49783819913864136, -0.2...</td>\n",
       "      <td>positive</td>\n",
       "      <td>3.0</td>\n",
       "      <td>here interesting tidbit what the like off pert...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>false dichotomy either you are for for bjp you...</td>\n",
       "      <td>[-0.6038466691970825, 0.2866456210613251, -0.3...</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>false dichotomy either you are for for bjp you...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>angry namo bhaktas the survival the angry namo...</td>\n",
       "      <td>[-1.20363450050354, -1.119809627532959, -0.183...</td>\n",
       "      <td>positive</td>\n",
       "      <td>3.0</td>\n",
       "      <td>angry namo bhaktas the survival the angry namo...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>this would issue these people were prosecuted ...</td>\n",
       "      <td>[-0.853580892086029, 0.8160178661346436, 0.117...</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>this would issue these people were prosecuted ...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>hate free india would boring love hate relatio...</td>\n",
       "      <td>[-0.28927552700042725, -0.9648609757423401, -0...</td>\n",
       "      <td>positive</td>\n",
       "      <td>9.0</td>\n",
       "      <td>hate free india would boring love hate relati...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>this getting bit silly now</td>\n",
       "      <td>[-1.1343425512313843, -0.030997686088085175, 0...</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>this getting bit silly now</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>giroud should done better but great ball rosicky</td>\n",
       "      <td>[-1.308074951171875, -0.03950951248407364, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>giroud should done better but great ball rosicky</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>jakiro spotted the middle top maybe</td>\n",
       "      <td>[-2.2450177669525146, -0.5104915499687195, -0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>5.0</td>\n",
       "      <td>jakiro spotted the middle top maybe</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>won vote for aap anymore that for sure though ...</td>\n",
       "      <td>[-0.7843935489654541, -0.32822510600090027, 0....</td>\n",
       "      <td>positive</td>\n",
       "      <td>3.0</td>\n",
       "      <td>won vote for aap anymore that for sure though...</td>\n",
       "      <td>negative</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>regardless the opposition all girouds goals ha...</td>\n",
       "      <td>[-1.635783076286316, 0.30238792300224304, -0.7...</td>\n",
       "      <td>positive</td>\n",
       "      <td>3.0</td>\n",
       "      <td>regardless the opposition all girouds goals ha...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>directly pleading people who oppose modi just ...</td>\n",
       "      <td>[-0.7491450905799866, -0.4327720105648041, 0.0...</td>\n",
       "      <td>positive</td>\n",
       "      <td>1.0</td>\n",
       "      <td>directly pleading people who oppose modi just...</td>\n",
       "      <td>positive</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-96a9eb02-4e31-433b-b84a-e11316f770e7')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-96a9eb02-4e31-433b-b84a-e11316f770e7 button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-96a9eb02-4e31-433b-b84a-e11316f770e7');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "\n",
       "<div id=\"df-f704a923-a437-41f8-9c75-5f01980219f3\">\n",
       "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-f704a923-a437-41f8-9c75-5f01980219f3')\"\n",
       "            title=\"Suggest charts.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
       "     width=\"24px\">\n",
       "    <g>\n",
       "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
       "    </g>\n",
       "</svg>\n",
       "  </button>\n",
       "\n",
       "<style>\n",
       "  .colab-df-quickchart {\n",
       "      --bg-color: #E8F0FE;\n",
       "      --fill-color: #1967D2;\n",
       "      --hover-bg-color: #E2EBFA;\n",
       "      --hover-fill-color: #174EA6;\n",
       "      --disabled-fill-color: #AAA;\n",
       "      --disabled-bg-color: #DDD;\n",
       "  }\n",
       "\n",
       "  [theme=dark] .colab-df-quickchart {\n",
       "      --bg-color: #3B4455;\n",
       "      --fill-color: #D2E3FC;\n",
       "      --hover-bg-color: #434B5C;\n",
       "      --hover-fill-color: #FFFFFF;\n",
       "      --disabled-bg-color: #3B4455;\n",
       "      --disabled-fill-color: #666;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart {\n",
       "    background-color: var(--bg-color);\n",
       "    border: none;\n",
       "    border-radius: 50%;\n",
       "    cursor: pointer;\n",
       "    display: none;\n",
       "    fill: var(--fill-color);\n",
       "    height: 32px;\n",
       "    padding: 0;\n",
       "    width: 32px;\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart:hover {\n",
       "    background-color: var(--hover-bg-color);\n",
       "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "    fill: var(--button-hover-fill-color);\n",
       "  }\n",
       "\n",
       "  .colab-df-quickchart-complete:disabled,\n",
       "  .colab-df-quickchart-complete:disabled:hover {\n",
       "    background-color: var(--disabled-bg-color);\n",
       "    fill: var(--disabled-fill-color);\n",
       "    box-shadow: none;\n",
       "  }\n",
       "\n",
       "  .colab-df-spinner {\n",
       "    border: 2px solid var(--fill-color);\n",
       "    border-color: transparent;\n",
       "    border-bottom-color: var(--fill-color);\n",
       "    animation:\n",
       "      spin 1s steps(1) infinite;\n",
       "  }\n",
       "\n",
       "  @keyframes spin {\n",
       "    0% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "      border-left-color: var(--fill-color);\n",
       "    }\n",
       "    20% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    30% {\n",
       "      border-color: transparent;\n",
       "      border-left-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    40% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-top-color: var(--fill-color);\n",
       "    }\n",
       "    60% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "    }\n",
       "    80% {\n",
       "      border-color: transparent;\n",
       "      border-right-color: var(--fill-color);\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "    90% {\n",
       "      border-color: transparent;\n",
       "      border-bottom-color: var(--fill-color);\n",
       "    }\n",
       "  }\n",
       "</style>\n",
       "\n",
       "  <script>\n",
       "    async function quickchart(key) {\n",
       "      const quickchartButtonEl =\n",
       "        document.querySelector('#' + key + ' button');\n",
       "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
       "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
       "      try {\n",
       "        const charts = await google.colab.kernel.invokeFunction(\n",
       "            'suggestCharts', [key], {});\n",
       "      } catch (error) {\n",
       "        console.error('Error during call to suggestCharts:', error);\n",
       "      }\n",
       "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
       "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
       "    }\n",
       "    (() => {\n",
       "      let quickchartButtonEl =\n",
       "        document.querySelector('#df-f704a923-a437-41f8-9c75-5f01980219f3 button');\n",
       "      quickchartButtonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "    })();\n",
       "  </script>\n",
       "</div>\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "                                             document  \\\n",
       "0   title edit 56dd brend ambasittur for vidya secret   \n",
       "1   this reminds kunkka old dota loading screen ar...   \n",
       "2           meanwhile the other news cms intenttarget   \n",
       "3                          lovely finish there giroud   \n",
       "4   glad see kurisu made with surprising results d...   \n",
       "5   wee jas lawful neutral god death magic and nec...   \n",
       "6                              holy fuck this amazing   \n",
       "7   yougaiz yougaiz who interested parineeti chopr...   \n",
       "8   not whole lot has changed except the fact that...   \n",
       "9   different times different cultures same point ...   \n",
       "10                                 too much attention   \n",
       "11  its nice and all but your monitors make want b...   \n",
       "12  india turns into toi comments section the mome...   \n",
       "13  nice build man pretty damn sexy can ask why ti...   \n",
       "14  rofl why are you asking permission you and you...   \n",
       "15  seriously did you infographic maker even consi...   \n",
       "16  cliche but you can wrong with cyric mean was m...   \n",
       "17  from whatever heard this the model modi speech...   \n",
       "18  heard there was direct line narendra modi whic...   \n",
       "19  truth told there not insignificant percentage ...   \n",
       "20  many them fear namo being prime minister could...   \n",
       "21  source will have accommodate hindus from bangl...   \n",
       "22  confirmed woman and this india 186 comments le...   \n",
       "23  prepared for downvotes but after watching seve...   \n",
       "24  delhi not sleeping after long day see congress...   \n",
       "25  would like bjp come out support scrapping sec ...   \n",
       "26  update still found debris black boxes evidence...   \n",
       "27  there one tool bjp can use their manifesto whi...   \n",
       "28                                            wtf why   \n",
       "29                               fantastic strike the   \n",
       "30  you mean the ruling coalition government hatch...   \n",
       "31  before used anti rss result anti bjp very skep...   \n",
       "32  first understand that you are not anyway contr...   \n",
       "33  personally for shooting muslims and internetof...   \n",
       "34  nice build one thing caught eye absolute splur...   \n",
       "35                looks shit now but still proud made   \n",
       "36  what wrong with that another lame ass attempt ...   \n",
       "37  how difficult was get the length and bend the ...   \n",
       "38  very impressed with gnabry movement and linkin...   \n",
       "39  here interesting tidbit what the like off pert...   \n",
       "40  false dichotomy either you are for for bjp you...   \n",
       "41  angry namo bhaktas the survival the angry namo...   \n",
       "42  this would issue these people were prosecuted ...   \n",
       "43  hate free india would boring love hate relatio...   \n",
       "44                         this getting bit silly now   \n",
       "45   giroud should done better but great ball rosicky   \n",
       "46                jakiro spotted the middle top maybe   \n",
       "47  won vote for aap anymore that for sure though ...   \n",
       "48  regardless the opposition all girouds goals ha...   \n",
       "49  directly pleading people who oppose modi just ...   \n",
       "\n",
       "                 sentence_embedding_small_bert_L2_128 sentiment  \\\n",
       "0   [-0.13924618065357208, 0.03819392994046211, -0...  positive   \n",
       "1   [-0.05514780059456825, -0.02986345998942852, -...  positive   \n",
       "2   [-1.3784979581832886, -0.05633991211652756, 0....  positive   \n",
       "3   [-1.026403546333313, -0.5962088108062744, -0.5...  positive   \n",
       "4   [-1.3281804323196411, -0.3425588011741638, 0.2...  positive   \n",
       "5   [-1.090584635734558, -0.39823225140571594, -0....  positive   \n",
       "6   [-2.318075656890869, -0.10535052418708801, -0....  positive   \n",
       "7   [-0.7263230085372925, -0.9229655861854553, 0.1...  positive   \n",
       "8   [-1.1650828123092651, 0.09717072546482086, -0....  positive   \n",
       "9   [-1.5615334510803223, -0.6228992938995361, -0....  positive   \n",
       "10  [-1.473575234413147, 0.6288167834281921, -0.68...  positive   \n",
       "11  [-0.8991073966026306, 0.8156149983406067, -0.2...  positive   \n",
       "12  [-0.7343364357948303, -0.12650255858898163, 0....  positive   \n",
       "13  [-1.21924889087677, 0.21342627704143524, -0.40...  positive   \n",
       "14  [-0.8997104167938232, 0.45302870869636536, -0....  positive   \n",
       "15  [-0.8621772527694702, 0.4609760046005249, -0.1...  positive   \n",
       "16  [-1.3570650815963745, -0.10502084344625473, -0...  positive   \n",
       "17  [-0.8209349513053894, 0.2195633053779602, -0.2...  positive   \n",
       "18  [-0.4502873718738556, -0.10798719525337219, -0...  positive   \n",
       "19  [-0.6922494173049927, 0.08739931136369705, -0....  positive   \n",
       "20  [-1.3202203512191772, -0.021619228646159172, -...  positive   \n",
       "21  [-0.6071749329566956, 0.21432138979434967, -0....  positive   \n",
       "22  [-0.7401843070983887, -0.4919162094593048, -0....  positive   \n",
       "23  [-0.5390527844429016, 1.0651843547821045, -0.5...  positive   \n",
       "24  [-1.3164680004119873, 0.059689976274967194, -0...  positive   \n",
       "25  [-0.39008525013923645, 0.6130499243736267, -0....  positive   \n",
       "26  [-0.5251181721687317, 0.5843355059623718, -0.2...  positive   \n",
       "27  [-0.42395493388175964, 0.3328923285007477, -0....  positive   \n",
       "28  [-1.0021588802337646, 1.2250791788101196, 0.05...  positive   \n",
       "29  [-0.6758270859718323, -0.2134172022342682, -0....  positive   \n",
       "30  [-0.5493559837341309, -0.2645500600337982, -0....  positive   \n",
       "31  [-0.11697939038276672, 0.26724380254745483, 0....  positive   \n",
       "32  [-1.1990007162094116, -0.23811395466327667, -0...  positive   \n",
       "33  [-1.314710259437561, -0.07083063572645187, -0....  positive   \n",
       "34  [-0.3646998703479767, -0.6708006262779236, -0....  positive   \n",
       "35  [-1.128523588180542, 0.31619158387184143, 0.02...  positive   \n",
       "36  [-1.9695912599563599, 0.27932408452033997, 0.0...  positive   \n",
       "37  [-1.2320657968521118, 0.9790331721305847, -0.5...  positive   \n",
       "38  [-0.3107994794845581, 0.3307916522026062, -0.1...  positive   \n",
       "39  [-0.308876633644104, 0.49783819913864136, -0.2...  positive   \n",
       "40  [-0.6038466691970825, 0.2866456210613251, -0.3...  positive   \n",
       "41  [-1.20363450050354, -1.119809627532959, -0.183...  positive   \n",
       "42  [-0.853580892086029, 0.8160178661346436, 0.117...  positive   \n",
       "43  [-0.28927552700042725, -0.9648609757423401, -0...  positive   \n",
       "44  [-1.1343425512313843, -0.030997686088085175, 0...  positive   \n",
       "45  [-1.308074951171875, -0.03950951248407364, -0....  positive   \n",
       "46  [-2.2450177669525146, -0.5104915499687195, -0....  positive   \n",
       "47  [-0.7843935489654541, -0.32822510600090027, 0....  positive   \n",
       "48  [-1.635783076286316, 0.30238792300224304, -0.7...  positive   \n",
       "49  [-0.7491450905799866, -0.4327720105648041, 0.0...  positive   \n",
       "\n",
       "   sentiment_confidence                                               text  \\\n",
       "0                   2.0  title edit 56dd brend ambasittur for vidya sec...   \n",
       "1                   2.0  this reminds kunkka old dota loading screen ar...   \n",
       "2                   4.0         meanwhile the other news cms intenttarget    \n",
       "3                   9.0                         lovely finish there giroud   \n",
       "4                   4.0  glad see kurisu made with surprising results d...   \n",
       "5                   4.0  wee jas lawful neutral god death magic and nec...   \n",
       "6                   2.0                            holy fuck this amazing    \n",
       "7                   2.0  yougaiz yougaiz who interested parineeti chopr...   \n",
       "8                   3.0  not whole lot has changed except the fact that...   \n",
       "9                   1.0  different times different cultures same point ...   \n",
       "10                  1.0                                too much attention    \n",
       "11                  3.0  its nice and all but your monitors make want b...   \n",
       "12                  1.0   india turns into toi comments section the mom...   \n",
       "13                  1.0  nice build man pretty damn sexy can ask why ti...   \n",
       "14                  1.0  rofl why are you asking permission you and you...   \n",
       "15                  2.0  seriously did you infographic maker even consi...   \n",
       "16                  3.0   cliche but you can wrong with cyric mean was ...   \n",
       "17                  6.0  from whatever heard this the model modi speech...   \n",
       "18                  1.0   heard there was direct line narendra modi whi...   \n",
       "19                  1.0  truth told there not insignificant percentage ...   \n",
       "20                  7.0   many them fear namo being prime minister coul...   \n",
       "21                  4.0   source will have accommodate hindus from bang...   \n",
       "22                  1.0   confirmed woman and this india 186 comments l...   \n",
       "23                  1.0   prepared for downvotes but after watching sev...   \n",
       "24                  7.0   delhi not sleeping after long day see congres...   \n",
       "25                  1.0   would like bjp come out support scrapping sec...   \n",
       "26                  4.0   update still found debris black boxes evidenc...   \n",
       "27                  3.0  there one tool bjp can use their manifesto whi...   \n",
       "28                  1.0                                           wtf why    \n",
       "29                  2.0                              fantastic strike the    \n",
       "30                  2.0  you mean the ruling coalition government hatch...   \n",
       "31                  1.0   before used anti rss result anti bjp very ske...   \n",
       "32                  7.0  first understand that you are not anyway contr...   \n",
       "33                  5.0  personally for shooting muslims and internetof...   \n",
       "34                  4.0  nice build one thing caught eye absolute splur...   \n",
       "35                  4.0               looks shit now but still proud made    \n",
       "36                  1.0  what wrong with that another lame ass attempt ...   \n",
       "37                  4.0  how difficult was get the length and bend the ...   \n",
       "38                  5.0   very impressed with gnabry movement and linki...   \n",
       "39                  3.0  here interesting tidbit what the like off pert...   \n",
       "40                  1.0  false dichotomy either you are for for bjp you...   \n",
       "41                  3.0  angry namo bhaktas the survival the angry namo...   \n",
       "42                  1.0  this would issue these people were prosecuted ...   \n",
       "43                  9.0   hate free india would boring love hate relati...   \n",
       "44                  1.0                        this getting bit silly now    \n",
       "45                  1.0  giroud should done better but great ball rosicky    \n",
       "46                  5.0               jakiro spotted the middle top maybe    \n",
       "47                  3.0   won vote for aap anymore that for sure though...   \n",
       "48                  3.0  regardless the opposition all girouds goals ha...   \n",
       "49                  1.0   directly pleading people who oppose modi just...   \n",
       "\n",
       "           y  \n",
       "0   negative  \n",
       "1   positive  \n",
       "2   negative  \n",
       "3   positive  \n",
       "4   positive  \n",
       "5   positive  \n",
       "6   positive  \n",
       "7   positive  \n",
       "8   positive  \n",
       "9   positive  \n",
       "10  positive  \n",
       "11  positive  \n",
       "12  positive  \n",
       "13  positive  \n",
       "14  positive  \n",
       "15  negative  \n",
       "16  negative  \n",
       "17  positive  \n",
       "18  positive  \n",
       "19  positive  \n",
       "20  positive  \n",
       "21  negative  \n",
       "22  positive  \n",
       "23  negative  \n",
       "24  negative  \n",
       "25  negative  \n",
       "26  negative  \n",
       "27  positive  \n",
       "28  negative  \n",
       "29  positive  \n",
       "30  negative  \n",
       "31  positive  \n",
       "32  positive  \n",
       "33  negative  \n",
       "34  positive  \n",
       "35  positive  \n",
       "36  negative  \n",
       "37  positive  \n",
       "38  positive  \n",
       "39  negative  \n",
       "40  negative  \n",
       "41  negative  \n",
       "42  negative  \n",
       "43  negative  \n",
       "44  negative  \n",
       "45  positive  \n",
       "46  positive  \n",
       "47  negative  \n",
       "48  positive  \n",
       "49  positive  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Train longer!\n",
    "trainable_pipe = nlp.load('train.sentiment')\n",
    "trainable_pipe['trainable_sentiment_dl'].setMaxEpochs(5)\n",
    "fitted_pipe = trainable_pipe.fit(train_df.iloc[:50])\n",
    "# predict with the trainable pipeline on dataset and get predictions\n",
    "preds = fitted_pipe.predict(train_df.iloc[:50],output_level='document')\n",
    "\n",
    "#sentence detector that is part of the pipe generates sone NaNs. lets drop them first\n",
    "preds.dropna(inplace=True)\n",
    "print(classification_report(preds['y'], preds['sentiment']))\n",
    "\n",
    "preds"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "qFoT-s1MjTSS"
   },
   "source": [
    "# Try training with different Embeddings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "nxWFzQOhjWC8",
    "outputId": "29e977d1-d916-4b2c-db7f-3acad2f6bcaa"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "For language <am> NLU provides the following Models : \n",
      "nlu.load('am.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_amharic\n",
      "For language <de> NLU provides the following Models : \n",
      "nlu.load('de.embed_sentence.bert.base_cased') returns Spark NLP model_anno_obj sent_bert_base_cased\n",
      "For language <el> NLU provides the following Models : \n",
      "nlu.load('el.embed_sentence.bert.base_uncased') returns Spark NLP model_anno_obj sent_bert_base_uncased\n",
      "For language <en> NLU provides the following Models : \n",
      "nlu.load('en.embed_sentence') returns Spark NLP model_anno_obj tfhub_use\n",
      "nlu.load('en.embed_sentence.albert') returns Spark NLP model_anno_obj albert_base_uncased\n",
      "nlu.load('en.embed_sentence.bert') returns Spark NLP model_anno_obj sent_bert_base_uncased\n",
      "nlu.load('en.embed_sentence.bert.base_uncased_legal') returns Spark NLP model_anno_obj sent_bert_base_uncased_legal\n",
      "nlu.load('en.embed_sentence.bert.finetuned') returns Spark NLP model_anno_obj sbert_setfit_finetuned_financial_text_classification\n",
      "nlu.load('en.embed_sentence.bert.pubmed') returns Spark NLP model_anno_obj sent_bert_pubmed\n",
      "nlu.load('en.embed_sentence.bert.pubmed_squad2') returns Spark NLP model_anno_obj sent_bert_pubmed_squad2\n",
      "nlu.load('en.embed_sentence.bert.wiki_books') returns Spark NLP model_anno_obj sent_bert_wiki_books\n",
      "nlu.load('en.embed_sentence.bert.wiki_books_mnli') returns Spark NLP model_anno_obj sent_bert_wiki_books_mnli\n",
      "nlu.load('en.embed_sentence.bert.wiki_books_qnli') returns Spark NLP model_anno_obj sent_bert_wiki_books_qnli\n",
      "nlu.load('en.embed_sentence.bert.wiki_books_qqp') returns Spark NLP model_anno_obj sent_bert_wiki_books_qqp\n",
      "nlu.load('en.embed_sentence.bert.wiki_books_squad2') returns Spark NLP model_anno_obj sent_bert_wiki_books_squad2\n",
      "nlu.load('en.embed_sentence.bert.wiki_books_sst2') returns Spark NLP model_anno_obj sent_bert_wiki_books_sst2\n",
      "nlu.load('en.embed_sentence.bert_base_cased') returns Spark NLP model_anno_obj sent_bert_base_cased\n",
      "nlu.load('en.embed_sentence.bert_base_uncased') returns Spark NLP model_anno_obj sent_bert_base_uncased\n",
      "nlu.load('en.embed_sentence.bert_large_cased') returns Spark NLP model_anno_obj sent_bert_large_cased\n",
      "nlu.load('en.embed_sentence.bert_large_uncased') returns Spark NLP model_anno_obj sent_bert_large_uncased\n",
      "nlu.load('en.embed_sentence.bert_use_cmlm_en_base') returns Spark NLP model_anno_obj sent_bert_use_cmlm_en_base\n",
      "nlu.load('en.embed_sentence.bert_use_cmlm_en_large') returns Spark NLP model_anno_obj sent_bert_use_cmlm_en_large\n",
      "nlu.load('en.embed_sentence.biobert.clinical_base_cased') returns Spark NLP model_anno_obj sent_biobert_clinical_base_cased\n",
      "nlu.load('en.embed_sentence.biobert.discharge_base_cased') returns Spark NLP model_anno_obj sent_biobert_discharge_base_cased\n",
      "nlu.load('en.embed_sentence.biobert.pmc_base_cased') returns Spark NLP model_anno_obj sent_biobert_pmc_base_cased\n",
      "nlu.load('en.embed_sentence.biobert.pubmed_base_cased') returns Spark NLP model_anno_obj sent_biobert_pubmed_base_cased\n",
      "nlu.load('en.embed_sentence.biobert.pubmed_large_cased') returns Spark NLP model_anno_obj sent_biobert_pubmed_large_cased\n",
      "nlu.load('en.embed_sentence.biobert.pubmed_pmc_base_cased') returns Spark NLP model_anno_obj sent_biobert_pubmed_pmc_base_cased\n",
      "nlu.load('en.embed_sentence.covidbert.large_uncased') returns Spark NLP model_anno_obj sent_covidbert_large_uncased\n",
      "nlu.load('en.embed_sentence.distil_roberta.distilled_base') returns Spark NLP model_anno_obj sent_distilroberta_base\n",
      "nlu.load('en.embed_sentence.doc2vec') returns Spark NLP model_anno_obj doc2vec_gigaword_300\n",
      "nlu.load('en.embed_sentence.doc2vec.gigaword_300') returns Spark NLP model_anno_obj doc2vec_gigaword_300\n",
      "nlu.load('en.embed_sentence.doc2vec.gigaword_wiki_300') returns Spark NLP model_anno_obj doc2vec_gigaword_wiki_300\n",
      "nlu.load('en.embed_sentence.electra') returns Spark NLP model_anno_obj sent_electra_small_uncased\n",
      "nlu.load('en.embed_sentence.electra_base_uncased') returns Spark NLP model_anno_obj sent_electra_base_uncased\n",
      "nlu.load('en.embed_sentence.electra_large_uncased') returns Spark NLP model_anno_obj sent_electra_large_uncased\n",
      "nlu.load('en.embed_sentence.electra_small_uncased') returns Spark NLP model_anno_obj sent_electra_small_uncased\n",
      "nlu.load('en.embed_sentence.roberta.base') returns Spark NLP model_anno_obj sent_roberta_base\n",
      "nlu.load('en.embed_sentence.roberta.large') returns Spark NLP model_anno_obj sent_roberta_large\n",
      "nlu.load('en.embed_sentence.small_bert_L10_128') returns Spark NLP model_anno_obj sent_small_bert_L10_128\n",
      "nlu.load('en.embed_sentence.small_bert_L10_256') returns Spark NLP model_anno_obj sent_small_bert_L10_256\n",
      "nlu.load('en.embed_sentence.small_bert_L10_512') returns Spark NLP model_anno_obj sent_small_bert_L10_512\n",
      "nlu.load('en.embed_sentence.small_bert_L10_768') returns Spark NLP model_anno_obj sent_small_bert_L10_768\n",
      "nlu.load('en.embed_sentence.small_bert_L12_128') returns Spark NLP model_anno_obj sent_small_bert_L12_128\n",
      "nlu.load('en.embed_sentence.small_bert_L12_256') returns Spark NLP model_anno_obj sent_small_bert_L12_256\n",
      "nlu.load('en.embed_sentence.small_bert_L12_512') returns Spark NLP model_anno_obj sent_small_bert_L12_512\n",
      "nlu.load('en.embed_sentence.small_bert_L12_768') returns Spark NLP model_anno_obj sent_small_bert_L12_768\n",
      "nlu.load('en.embed_sentence.small_bert_L2_128') returns Spark NLP model_anno_obj sent_small_bert_L2_128\n",
      "nlu.load('en.embed_sentence.small_bert_L2_256') returns Spark NLP model_anno_obj sent_small_bert_L2_256\n",
      "nlu.load('en.embed_sentence.small_bert_L2_512') returns Spark NLP model_anno_obj sent_small_bert_L2_512\n",
      "nlu.load('en.embed_sentence.small_bert_L2_768') returns Spark NLP model_anno_obj sent_small_bert_L2_768\n",
      "nlu.load('en.embed_sentence.small_bert_L4_128') returns Spark NLP model_anno_obj sent_small_bert_L4_128\n",
      "nlu.load('en.embed_sentence.small_bert_L4_256') returns Spark NLP model_anno_obj sent_small_bert_L4_256\n",
      "nlu.load('en.embed_sentence.small_bert_L4_512') returns Spark NLP model_anno_obj sent_small_bert_L4_512\n",
      "nlu.load('en.embed_sentence.small_bert_L4_768') returns Spark NLP model_anno_obj sent_small_bert_L4_768\n",
      "nlu.load('en.embed_sentence.small_bert_L6_128') returns Spark NLP model_anno_obj sent_small_bert_L6_128\n",
      "nlu.load('en.embed_sentence.small_bert_L6_256') returns Spark NLP model_anno_obj sent_small_bert_L6_256\n",
      "nlu.load('en.embed_sentence.small_bert_L6_512') returns Spark NLP model_anno_obj sent_small_bert_L6_512\n",
      "nlu.load('en.embed_sentence.small_bert_L6_768') returns Spark NLP model_anno_obj sent_small_bert_L6_768\n",
      "nlu.load('en.embed_sentence.small_bert_L8_128') returns Spark NLP model_anno_obj sent_small_bert_L8_128\n",
      "nlu.load('en.embed_sentence.small_bert_L8_256') returns Spark NLP model_anno_obj sent_small_bert_L8_256\n",
      "nlu.load('en.embed_sentence.small_bert_L8_512') returns Spark NLP model_anno_obj sent_small_bert_L8_512\n",
      "nlu.load('en.embed_sentence.small_bert_L8_768') returns Spark NLP model_anno_obj sent_small_bert_L8_768\n",
      "nlu.load('en.embed_sentence.tfhub_use') returns Spark NLP model_anno_obj tfhub_use\n",
      "nlu.load('en.embed_sentence.tfhub_use.lg') returns Spark NLP model_anno_obj tfhub_use_lg\n",
      "nlu.load('en.embed_sentence.use') returns Spark NLP model_anno_obj tfhub_use\n",
      "nlu.load('en.embed_sentence.use.lg') returns Spark NLP model_anno_obj tfhub_use_lg\n",
      "For language <es> NLU provides the following Models : \n",
      "nlu.load('es.embed_sentence.bert.base_cased') returns Spark NLP model_anno_obj sent_bert_base_cased\n",
      "nlu.load('es.embed_sentence.bert.base_uncased') returns Spark NLP model_anno_obj sent_bert_base_uncased\n",
      "For language <fi> NLU provides the following Models : \n",
      "nlu.load('fi.embed_sentence.bert') returns Spark NLP model_anno_obj bert_base_finnish_uncased\n",
      "nlu.load('fi.embed_sentence.bert.cased') returns Spark NLP model_anno_obj bert_base_finnish_cased\n",
      "nlu.load('fi.embed_sentence.bert.uncased') returns Spark NLP model_anno_obj bert_base_finnish_uncased\n",
      "For language <ha> NLU provides the following Models : \n",
      "nlu.load('ha.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_hausa\n",
      "For language <ig> NLU provides the following Models : \n",
      "nlu.load('ig.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_igbo\n",
      "For language <lg> NLU provides the following Models : \n",
      "nlu.load('lg.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_luganda\n",
      "For language <nl> NLU provides the following Models : \n",
      "nlu.load('nl.embed_sentence.bert.base_cased') returns Spark NLP model_anno_obj sent_bert_base_cased\n",
      "For language <pcm> NLU provides the following Models : \n",
      "nlu.load('pcm.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_naija\n",
      "For language <pt> NLU provides the following Models : \n",
      "nlu.load('pt.embed_sentence.bert.base_legal') returns Spark NLP model_anno_obj sbert_legal_bertimbau_base_tsdae_sts\n",
      "nlu.load('pt.embed_sentence.bert.cased_large_legal') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.1\n",
      "nlu.load('pt.embed_sentence.bert.large_legal') returns Spark NLP model_anno_obj sbert_legal_bertimbau_large_gpl_sts\n",
      "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.10.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.10\n",
      "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.2.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.2\n",
      "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.3.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.3\n",
      "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.4.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.4\n",
      "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.5.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.5\n",
      "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.7.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.7\n",
      "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.8.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.8\n",
      "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v0.9.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v0.9\n",
      "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_sts_v1.0.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_sts_v1.0\n",
      "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_v0.11_gpl_nli_sts_v0.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_v0.11_gpl_nli_sts_v0\n",
      "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_v0.11_gpl_nli_sts_v1.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_v0.11_gpl_nli_sts_v1\n",
      "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_v0.11_nli_sts_v0.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_v0.11_nli_sts_v0\n",
      "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_v0.11_nli_sts_v1.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_v0.11_nli_sts_v1\n",
      "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_v0.11_sts_v0.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_v0.11_sts_v0\n",
      "nlu.load('pt.embed_sentence.bert.legal.cased_large_mlm_v0.11_sts_v1.by_stjiris') returns Spark NLP model_anno_obj sbert_bert_large_portuguese_cased_legal_mlm_v0.11_sts_v1\n",
      "nlu.load('pt.embed_sentence.bert.v2_base_legal') returns Spark NLP model_anno_obj sbert_legal_bertimbau_sts_base_ma_v2\n",
      "nlu.load('pt.embed_sentence.bert.v2_large_legal') returns Spark NLP model_anno_obj sbert_legal_bertimbau_large_tsdae_sts_v2\n",
      "nlu.load('pt.embed_sentence.bertimbau.legal.assin.base.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_sts_base_ma\n",
      "nlu.load('pt.embed_sentence.bertimbau.legal.assin2.base.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_sts_base\n",
      "nlu.load('pt.embed_sentence.bertimbau.legal.large_sts_by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_sts_large\n",
      "nlu.load('pt.embed_sentence.bertimbau.legal.large_sts_ma.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_sts_large_ma\n",
      "nlu.load('pt.embed_sentence.bertimbau.legal.large_sts_ma_v3.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_sts_large_ma_v3\n",
      "nlu.load('pt.embed_sentence.bertimbau.legal.large_tsdae_sts.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_large_tsdae_sts\n",
      "nlu.load('pt.embed_sentence.bertimbau.legal.large_tsdae_sts_v4.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_large_tsdae_sts_v4\n",
      "nlu.load('pt.embed_sentence.bertimbau.legal.large_tsdae_v4_gpl_sts.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_large_tsdae_v4_gpl_sts\n",
      "nlu.load('pt.embed_sentence.bertimbau.legal.v2_large_sts_v2.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_sts_large_v2\n",
      "nlu.load('pt.embed_sentence.bertimbau.legal.v2_large_v2_sts.by_rufimelo') returns Spark NLP model_anno_obj sbert_legal_bertimbau_large_v2_sts\n",
      "For language <rw> NLU provides the following Models : \n",
      "nlu.load('rw.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_kinyarwanda\n",
      "For language <sv> NLU provides the following Models : \n",
      "nlu.load('sv.embed_sentence.bert.base_cased') returns Spark NLP model_anno_obj sent_bert_base_cased\n",
      "For language <sw> NLU provides the following Models : \n",
      "nlu.load('sw.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_swahili\n",
      "For language <wo> NLU provides the following Models : \n",
      "nlu.load('wo.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_wolof\n",
      "For language <xx> NLU provides the following Models : \n",
      "nlu.load('xx.embed_sentence') returns Spark NLP model_anno_obj sent_bert_multi_cased\n",
      "nlu.load('xx.embed_sentence.bert') returns Spark NLP model_anno_obj sent_bert_multi_cased\n",
      "nlu.load('xx.embed_sentence.bert.cased') returns Spark NLP model_anno_obj sent_bert_multi_cased\n",
      "nlu.load('xx.embed_sentence.bert.muril') returns Spark NLP model_anno_obj sent_bert_muril\n",
      "nlu.load('xx.embed_sentence.bert_use_cmlm_multi_base') returns Spark NLP model_anno_obj sent_bert_use_cmlm_multi_base\n",
      "nlu.load('xx.embed_sentence.bert_use_cmlm_multi_base_br') returns Spark NLP model_anno_obj sent_bert_use_cmlm_multi_base_br\n",
      "nlu.load('xx.embed_sentence.labse') returns Spark NLP model_anno_obj labse\n",
      "nlu.load('xx.embed_sentence.xlm_roberta.base') returns Spark NLP model_anno_obj sent_xlm_roberta_base\n",
      "For language <yo> NLU provides the following Models : \n",
      "nlu.load('yo.embed_sentence.xlm_roberta') returns Spark NLP model_anno_obj sent_xlm_roberta_base_finetuned_yoruba\n",
      "For language <zh> NLU provides the following Models : \n",
      "nlu.load('zh.embed_sentence.bert') returns Spark NLP model_anno_obj sbert_chinese_qmc_finance_v1\n",
      "nlu.load('zh.embed_sentence.bert.distilled') returns Spark NLP model_anno_obj sbert_chinese_qmc_finance_v1_distill\n"
     ]
    }
   ],
   "source": [
    "# We can use nlu.print_components(action='embed_sentence') to see every possibler sentence embedding we could use. Lets use bert!\n",
    "nlp.nlu.print_components(action='embed_sentence')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "IKK_Ii_gjJfF",
    "outputId": "c1ba963c-f065-4eed-88a8-35316200b992"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning::Spark Session already created, some configs may not take.\n",
      "Warning::Spark Session already created, some configs may not take.\n",
      "sent_small_bert_L12_768 download started this may take some time.\n",
      "Approximate size to download 392.9 MB\n",
      "[OK!]\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "    negative       0.87      0.78      0.82       300\n",
      "     neutral       0.00      0.00      0.00         0\n",
      "    positive       0.91      0.68      0.77       300\n",
      "\n",
      "    accuracy                           0.73       600\n",
      "   macro avg       0.59      0.49      0.53       600\n",
      "weighted avg       0.89      0.73      0.80       600\n",
      "\n"
     ]
    }
   ],
   "source": [
    "trainable_pipe = nlp.load('en.embed_sentence.small_bert_L12_768 train.sentiment')\n",
    "# We need to train longer and user smaller LR for NON-USE based sentence embeddings usually\n",
    "# We could tune the hyperparameters further with hyperparameter tuning methods like gridsearch\n",
    "# Also longer training gives more accuracy\n",
    "trainable_pipe['trainable_sentiment_dl'].setMaxEpochs(70)\n",
    "trainable_pipe['trainable_sentiment_dl'].setLr(0.0005)\n",
    "fitted_pipe = trainable_pipe.fit(train_df)\n",
    "# predict with the trainable pipeline on dataset and get predictions\n",
    "preds = fitted_pipe.predict(train_df,output_level='document')\n",
    "\n",
    "#sentence detector that is part of the pipe generates some NaNs. lets drop them first\n",
    "preds.dropna(inplace=True)\n",
    "print(classification_report(preds['y'], preds['sentiment']))\n",
    "\n",
    "#preds"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "2BB-NwZUoHSe"
   },
   "source": [
    "# 5. Lets save the model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "id": "eLex095goHwm"
   },
   "outputs": [],
   "source": [
    "stored_model_path = './models/classifier_dl_trained'\n",
    "fitted_pipe.save(stored_model_path)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "e_b2DPd4rCiU"
   },
   "source": [
    "# 6. Lets load the model from HDD.\n",
    "This makes Offlien NLU usage possible!   \n",
    "You need to call nlu.load(path=path_to_the_pipe) to load a model/pipeline from disk."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 133
    },
    "id": "SO4uz45MoRgp",
    "outputId": "ac7bafb1-cd05-4082-86f8-403384f6edfa"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning::Spark Session already created, some configs may not take.\n",
      "Warning::Spark Session already created, some configs may not take.\n",
      "Warning::Spark Session already created, some configs may not take.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "  <div id=\"df-ea6d3e8c-5583-4cea-af4f-d7ffaecf78a7\" class=\"colab-df-container\">\n",
       "    <div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>document</th>\n",
       "      <th>sentence_embedding_from_disk</th>\n",
       "      <th>sentiment</th>\n",
       "      <th>sentiment_confidence</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Indian prime minister was assinated</td>\n",
       "      <td>[-0.09739536792039871, 0.23939242959022522, 0....</td>\n",
       "      <td>negative</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>\n",
       "    <div class=\"colab-df-buttons\">\n",
       "\n",
       "  <div class=\"colab-df-container\">\n",
       "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-ea6d3e8c-5583-4cea-af4f-d7ffaecf78a7')\"\n",
       "            title=\"Convert this dataframe to an interactive table.\"\n",
       "            style=\"display:none;\">\n",
       "\n",
       "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
       "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
       "  </svg>\n",
       "    </button>\n",
       "\n",
       "  <style>\n",
       "    .colab-df-container {\n",
       "      display:flex;\n",
       "      gap: 12px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert {\n",
       "      background-color: #E8F0FE;\n",
       "      border: none;\n",
       "      border-radius: 50%;\n",
       "      cursor: pointer;\n",
       "      display: none;\n",
       "      fill: #1967D2;\n",
       "      height: 32px;\n",
       "      padding: 0 0 0 0;\n",
       "      width: 32px;\n",
       "    }\n",
       "\n",
       "    .colab-df-convert:hover {\n",
       "      background-color: #E2EBFA;\n",
       "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
       "      fill: #174EA6;\n",
       "    }\n",
       "\n",
       "    .colab-df-buttons div {\n",
       "      margin-bottom: 4px;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert {\n",
       "      background-color: #3B4455;\n",
       "      fill: #D2E3FC;\n",
       "    }\n",
       "\n",
       "    [theme=dark] .colab-df-convert:hover {\n",
       "      background-color: #434B5C;\n",
       "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
       "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
       "      fill: #FFFFFF;\n",
       "    }\n",
       "  </style>\n",
       "\n",
       "    <script>\n",
       "      const buttonEl =\n",
       "        document.querySelector('#df-ea6d3e8c-5583-4cea-af4f-d7ffaecf78a7 button.colab-df-convert');\n",
       "      buttonEl.style.display =\n",
       "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
       "\n",
       "      async function convertToInteractive(key) {\n",
       "        const element = document.querySelector('#df-ea6d3e8c-5583-4cea-af4f-d7ffaecf78a7');\n",
       "        const dataTable =\n",
       "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
       "                                                    [key], {});\n",
       "        if (!dataTable) return;\n",
       "\n",
       "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
       "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
       "          + ' to learn more about interactive tables.';\n",
       "        element.innerHTML = '';\n",
       "        dataTable['output_type'] = 'display_data';\n",
       "        await google.colab.output.renderOutput(dataTable, element);\n",
       "        const docLink = document.createElement('div');\n",
       "        docLink.innerHTML = docLinkHtml;\n",
       "        element.appendChild(docLink);\n",
       "      }\n",
       "    </script>\n",
       "  </div>\n",
       "\n",
       "    </div>\n",
       "  </div>\n"
      ],
      "text/plain": [
       "                              document  \\\n",
       "0  Indian prime minister was assinated   \n",
       "\n",
       "                        sentence_embedding_from_disk sentiment  \\\n",
       "0  [-0.09739536792039871, 0.23939242959022522, 0....  negative   \n",
       "\n",
       "  sentiment_confidence  \n",
       "0                  0.0  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hdd_pipe = nlp.load(path=stored_model_path)\n",
    "\n",
    "preds = hdd_pipe.predict('Indian prime minister was assinated')\n",
    "preds"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "e0CVlkk9v6Qi",
    "outputId": "b82bb85a-9063-49ca-8be2-51f4f735b1ea"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The following parameters are configurable for this NLU pipeline (You can copy paste the examples) :\n",
      ">>> component_list['document_assembler'] has settable params:\n",
      "component_list['document_assembler'].setCleanupMode('shrink')                                    | Info: possible values: disabled, inplace, inplace_full, shrink, shrink_full, each, each_full, delete_full | Currently set to : shrink\n",
      ">>> component_list['bert_sentence_embeddings@sent_small_bert_L12_768'] has settable params:\n",
      "component_list['bert_sentence_embeddings@sent_small_bert_L12_768'].setBatchSize(8)               | Info: Size of every batch | Currently set to : 8\n",
      "component_list['bert_sentence_embeddings@sent_small_bert_L12_768'].setCaseSensitive(False)       | Info: whether to ignore case in tokens for embeddings matching | Currently set to : False\n",
      "component_list['bert_sentence_embeddings@sent_small_bert_L12_768'].setDimension(768)             | Info: Number of embedding dimensions | Currently set to : 768\n",
      "component_list['bert_sentence_embeddings@sent_small_bert_L12_768'].setMaxSentenceLength(128)     | Info: Max sentence length to process | Currently set to : 128\n",
      "component_list['bert_sentence_embeddings@sent_small_bert_L12_768'].setEngine('tensorflow')       | Info: Deep Learning engine used for this model | Currently set to : tensorflow\n",
      "component_list['bert_sentence_embeddings@sent_small_bert_L12_768'].setIsLong(False)              | Info: Use Long type instead of Int type for inputs buffer - Some Bert models require Long instead of Int. | Currently set to : False\n",
      "component_list['bert_sentence_embeddings@sent_small_bert_L12_768'].setStorageRef('sent_small_bert_L12_768')  | Info: unique reference name for identification | Currently set to : sent_small_bert_L12_768\n",
      ">>> component_list['sentiment_dl@sent_small_bert_L12_768'] has settable params:\n",
      "component_list['sentiment_dl@sent_small_bert_L12_768'].setThreshold(0.6)                         | Info: The minimum threshold for the final result otheriwse it will be neutral | Currently set to : 0.6\n",
      "component_list['sentiment_dl@sent_small_bert_L12_768'].setThresholdLabel('neutral')              | Info: In case the score is less than threshold, what should be the label. Default is neutral. | Currently set to : neutral\n",
      "component_list['sentiment_dl@sent_small_bert_L12_768'].setEngine('tensorflow')                   | Info: Deep Learning engine used for this model | Currently set to : tensorflow\n",
      "component_list['sentiment_dl@sent_small_bert_L12_768'].setClasses(['positive', 'negative'])      | Info: get the tags used to trained this SentimentDLModel | Currently set to : ['positive', 'negative']\n",
      "component_list['sentiment_dl@sent_small_bert_L12_768'].setStorageRef('sent_small_bert_L12_768')  | Info: unique reference name for identification | Currently set to : sent_small_bert_L12_768\n"
     ]
    }
   ],
   "source": [
    "hdd_pipe.print_info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "2LJTK79JKF9-"
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "colab": {
   "provenance": []
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
